'use strict';

var mongoose = require('mongoose'),
	Schema = mongoose.Schema;
var scoreSchema = new Schema({
	course: String,
	value: Number,
	rank: Number
}, {
	_id: false
})
var entrySchema = new Schema({
	student: {
		code: String,
		name: String
	},
	scores: [scoreSchema]
}, {
	_id: false
})
var ExamSchema = new Schema({
	title: String,
	klass: String,
	courses: [String],
	content: [entrySchema],
	creater:String,
	comment:String,//教师对本次考试的点评
	flag:Number,//0 学生只能看见自己的成绩 1 学生可查看所有人的成绩
	createtime: {
		type: Date,
		default: Date.now
	}
});

module.exports = mongoose.model('Exam', ExamSchema);
